<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> </title>
    <link rel="stylesheet" href="./lib/layui/css/layui.css" />
	<link rel="stylesheet" href="../css/default_style.css" />
</head>

<body>
    <script src="./lib/layui/layui.js"></script>
    <script src="./lib/jquery-3.7.0.js"></script>
    <script>
        var baseurl = "http://localhost:5500"
        layui.use('element', function () {
            var element = layui.element;
        })
        function loadData(){

        }

        function loadOne(){
            $.ajax({
				url: 'http://localhost:8080/post/list-all-hot-posts',
				method: 'POST',
				data: {
					"num":5
				},
				crossDomain: true,
				xhrFields: { withCredentials: true },
				success: function(msg){
					let list = msg.data.list;
					console.log(list)
					$(list).each(function(i,e){
						let str = "<li><a href='" + baseurl + "/pages/post.html?id=" + e.id + "'>";
						str += "`-" + e.title + "</a><div class='hot-post-author'><a href='" + baseurl + "/userPage.html?id=" + e.authorId + "'>" + e.authorName + "</a></div></li>";
					$(".hot-post-list-inner").append(str);
					// <li><a href="#">·-这是什么？从来</a><div class="hot-post-author"><a href="#">feaee</a></div></li>
					})

				},error:function(error){
					layer.msg("热帖获取失败~")

				}
			})
        }
    </script>
</body>

</html>